package com.study.javaOther.spel;

public class Context {
    private Object subject;
    private Object resource;
    private Object action;

    public Context(Object subject, Object resource, Object action) {
        this.subject = subject;
        this.resource = resource;
        this.action = action;
    }
    public Object getSubject() {
        return subject;
    }
    public void setSubject(Object subject) {
        this.subject = subject;
    }
    public Object getResource() {
        return resource;
    }
    public void setResource(Object resource) {
        this.resource = resource;
    }
    public Object getAction() {
        return action;
    }
    public void setAction(Object action) {
        this.action = action;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((action == null) ? 0 : action.hashCode());
        result = prime * result + ((resource == null) ? 0 : resource.hashCode());
        result = prime * result + ((subject == null) ? 0 : subject.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Context other = (Context) obj;
        if (action == null) {
            if (other.action != null)
                return false;
        } else if (!action.equals(other.action))
            return false;
        if (resource == null) {
            if (other.resource != null)
                return false;
        } else if (!resource.equals(other.resource))
            return false;
        if (subject == null) {
            if (other.subject != null)
                return false;
        } else if (!subject.equals(other.subject))
            return false;
        return true;
    }
}
